let {getNewmusic} = require("../../api/index")

Page({
  data:{
    bannerList:[],
    hotremList:[],
    newList:[]
  },
  onLoad(){
    let that = this
    wx.request({
      url: 'http://106.12.150.223:3000/banner',
      methods:"GET",
      success(res){

        that.setData({
          bannerList:res.data.banners
          
        })
      }
    }),
    wx.request({
      url: 'http://106.12.150.223:3000/toplist/detail',
      methods:"GET",
      success(res){
        console.log(res);
        that.setData({
          hotremList:res.data.list.slice(0,4)
          
        })
      }
    }),
    //封装获取新音乐的信息
    getNewmusic().then((res)=>{
      console.log(res)
      that.setData({
        newList:res.data.result
      })
  
    }).catch((err)=>{
      consolee.log(err)
    })
  },
  onShow(){
    console.log(this)
  },
  goInfo(e){
    //获取榜单id
    console.log(e)
    let id =e.currentTarget.dataset.id
    //跳转到热门榜单详情页
    wx.navigateTo({
      url: '../hotInfo/hotInfo?id='+id,
    })
    console.log(id)
  },
  goSearch(){
    wx.navigateTo({
      url: '../search/search',
    })
  }
  
})